<template>
  <div class="my_div">
    <img :src="dogImgUrl" alt="" />
    <p class="meihua" :style="{ backgroundColor: ColorStr }" @click="btn">
      {{ dogName }}
    </p>
  </div>
</template>

<script>
export default {
  props: ["dogImgUrl", "dogName"],
  data() {
    return {
      ColorStr: "",
    };
  },
  methods: {
    btn() {
      this.ColorStr = `
      rgb(${Math.floor(Math.random() * 256)},
      ${Math.floor(Math.random() * 256)},
      ${Math.floor(Math.random() * 256)})
      `;

      this.$emit("like", this.dogName);
    },
  },
};
</script>

<style>
.my_div {
  width: 250px;
  border: 1px solid black;
  text-align: center;
  float: left;
}

.my_div img {
  width: 100%;
  height: 400px;
}
.meihua{
  cursor: pointer;
}
</style>